﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Xml;
using System.IO;
using System.Windows.Forms;
using eRechnung_3_0.Properties;


namespace eRechnung_3_0
{
    public partial class FrmEbInterfaceSettings : Form
    {
        public FrmEbInterfaceSettings()
        {
            InitializeComponent();
            txtName.Text = Settings.Default.setName;
            txtBxBank.Text = Settings.Default.setBank;
            txtBxEmail.Text = Settings.Default.setEmail;
            txtBxKtonr.Text = Settings.Default.setKontonr;
            txtBxKtoWortlaut.Text = Settings.Default.setKontowortlaut;
            txtBxPhone.Text = Settings.Default.setTelNr;
            txtBxPLZ.Text = Settings.Default.setPLZ;
            txtBxStrasse.Text = Settings.Default.setStrasse;
            txtBxVATID.Text = Settings.Default.setVATID;
            txtBLZ.Text = Settings.Default.setBLZ;
            txtIBAN.Text = Settings.Default.setIBAN;
            txtBxOrt.Text = Settings.Default.setOrt;
            txtBxBillerContact.Text = Settings.Default.setBillerContact;
            this.dsInvoice.LoadMwStTab();
            decimal DefaultMwSt = Settings.Default.setMwStDefault;
            cBxDefaultMwSt.Text = DefaultMwSt.ToString("0.00");
            // Währung
            eRechnung_3_0.Globals.ThisDocument.InvXSD.FillCountryCCbox(cBxCurrency);
            // Bank Land
            eRechnung_3_0.Globals.ThisDocument.XlateTables.FillCountryCCbox(cBxBankCountry);
            // Rechnungsaussteller Land
            eRechnung_3_0.Globals.ThisDocument.XlateTables.FillCountryCCbox(cBxBillerCountry);
  
        }

        private void BtnCancel_Click(object sender, EventArgs e)
        {
            this.Close();

        }

        private void BtnSave_Click(object sender, EventArgs e)
        {

            Settings.Default.setName = txtName.Text;
            Settings.Default.setBank = txtBxBank.Text;
            Settings.Default.setEmail = txtBxEmail.Text;
            Settings.Default.setKontonr = txtBxKtonr.Text;
            Settings.Default.setKontowortlaut = txtBxKtoWortlaut.Text;
            Settings.Default.setTelNr = txtBxPhone.Text;
            Settings.Default.setPLZ = txtBxPLZ.Text;
            Settings.Default.setStrasse = txtBxStrasse.Text;
            Settings.Default.setVATID = txtBxVATID.Text;
            Settings.Default.setBLZ = txtBLZ.Text;
            Settings.Default.setIBAN = txtIBAN.Text;
            Settings.Default.setOrt = txtBxOrt.Text;
            Settings.Default.setBankLand = cBxBankCountry.SelectedItem.ToString();
            Settings.Default.setLand = cBxBillerCountry.SelectedItem.ToString();
            Settings.Default.setWhrg = cBxCurrency.SelectedItem.ToString();
            Settings.Default.setBillerContact = txtBxBillerContact.Text;
            Settings.Default.setMwStTab = this.dsInvoice.ToStringAsXml(this.dsInvoice.TblMWST);
            Settings.Default.setMwStDefault = decimal.Parse(cBxDefaultMwSt.Text);
            Settings.Default.Save();
            this.Close();
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.dataGridView1.Columns[e.ColumnIndex].Name == "BtnDel")
            {
                this.dataGridView1.Rows.RemoveAt(e.RowIndex);
            }

        }




    }
}
